package com.vhall.component.controller.anchors.adm;


import com.vhall.component.entity.anchors.dto.AnchorManagePageRspListVO;
import com.vhall.component.entity.anchors.vo.AnchorManageCreateVO;
import com.vhall.component.entity.anchors.vo.AnchorManagePageListVO;
import com.vhall.component.entity.page.vo.PageVO;
import com.vhall.component.plugin.common.enums.OperateTypeEnum;
import com.vhall.component.service.anchors.AnchorManageService;
import com.vhall.component.service.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * admin端 讲师表
 *
 * @author wangxing
 * @since 2022-09-28
 */
@RestController
@RequestMapping("/v4/anchor-manage/admin")
public class AdmAnchorManageController {

    @Resource
    private AnchorManageService service;

    /**
     * admin端-新增讲师账户
     *
     * @param vo 参数
     * @return 是否成功创建
     */
    @PostMapping("/create")
//    @TokenAuth("sys:anchormanage:create")
    @OperateLog(module = "讲师管理-管理端", type = OperateTypeEnum.CREATE, name = "新增讲师账户")
    public Boolean create(@Validated AnchorManageCreateVO vo) {
        return service.create(vo);
    }


    /**
     * admin端-编辑讲师账户
     *
     * @param vo 参数
     * @return 是否更新成功
     */
    @PostMapping("/update")
//    @TokenAuth("sys:anchormanage:update")
    @OperateLog(module = "讲师管理-管理端", type = OperateTypeEnum.UPDATE, name = "编辑讲师账户")
    public Boolean update(@Validated AnchorManageCreateVO vo) {
        return service.update(vo);
    }

    /**
     * admin端-是否推荐讲师账户
     *
     * @param vo 参数
     * @return 是否更新成功
     */
    @PostMapping("/recommend")
    @OperateLog(module = "讲师管理-管理端", type = OperateTypeEnum.UPDATE, name = "是否推荐讲师账户")
    public Boolean recommend(AnchorManageCreateVO vo) {
        return service.recommend(vo);
    }


    /**
     * admin端-删除讲师账户
     *
     * @return 是否删除成功
     */
    @PostMapping("/delete")
//    @TokenAuth("sys:anchormanage:delete")
    @OperateLog(module = "讲师管理-管理端", type = OperateTypeEnum.DELETE, name = "删除讲师账户")
    public Boolean delete(@RequestParam("ids") List<Integer> ids) {
        return service.delete(ids);
    }


    /**
     * admin端-讲师账户的分页列表
     *
     * @param vo 参数
     * @return 分页列表
     */
    @PostMapping("/list")
//    @TokenAuth("sys:anchormanage:list")
    public PageVO<AnchorManagePageRspListVO> list(AnchorManagePageListVO vo) {
        return service.pageList(vo);
    }
}

